home *** CD-ROM | disk | FTP | other *** search
/ Programming in Microsoft Windows with C# / Programacion en Microsoft Windows con C#.iso / Codigo / Texto y fuentes / HowdyWorld / HowdyWorld.cs next >
Encoding:
Text File  |  2002-05-02  |  1.1 KB  |  32 lines

  1. //-----------------------------------------
  2. // HowdyWorld.cs ⌐ 2001 by Charles Petzold
  3. //-----------------------------------------
  4. using System;
  5. using System.Drawing;
  6. using System.Windows.Forms;
  7.  
  8. class HowdyWorld: PrintableForm
  9. {
  10.      public new static void Main()
  11.      {
  12.           Application.Run(new HowdyWorld());
  13.      }
  14.      public HowdyWorld()
  15.      {
  16.           Text = "┐Que hay de nuevo?";
  17.           MinimumSize = SystemInformation.MinimumWindowSize + new Size(0,1);
  18.      }
  19.      protected override void DoPage(Graphics grfx, Color clr, int cx, int cy)
  20.      {
  21.           Font  font   = new Font("Times New Roman", 10, FontStyle.Italic);
  22.           SizeF sizef  = grfx.MeasureString(Text, font);
  23.           float fScale = Math.Min(cx / sizef.Width, cy / sizef.Height);
  24.  
  25.           font = new Font(font.Name, fScale * font.SizeInPoints, font.Style);
  26.           sizef = grfx.MeasureString(Text, font);
  27.  
  28.           grfx.DrawString(Text, font, new SolidBrush(clr), 
  29.                           (cx  - sizef.Width ) / 2, (cy - sizef.Height) / 2);
  30.      }
  31. }
  32.